<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Eureka Console</title>
</head>
<script src="jquery-3.3.1.js"></script>
<style>
    .shutdown{
        color: red;
        cursor: pointer;
    }
    .shutdown:hover{
        color: red;
    }
    .swagger{
        color: green;
        cursor: pointer;
    }
    .swagger:hover{
        color: green;
    }

</style>
<script>
    $.get("/", function(page){
        $("body").html(page);

        $("#instances tbody tr").each(function(){
            var _html = "&nbsp;<b><a class='swagger'>< Swagger-Doc ></a></b>" +
                "&nbsp;<b><a class='shutdown'>< Shutdown ></a></b>";
            $(this).find("td").eq(3).find("a").each(function () {
                $(this).after(_html);
            })
        })

        $(".shutdown").click(function () {
            var tr = $(this).parent().parent().parent();
            var application = tr.find("td").eq(0).find("b").html();
            var instance = $(this).parent().prev().prev().html();
            $.ajax({
                url: "/management/apps/" + application + "/instance/" + instance,
                type: "DELETE",
                success: function(){
                    window.location.reload();
                }
            })
        });

        $(".swagger").click(function () {
            var info = $(this).parent().prev().attr("href");
            var url = info.replace("actuator/info", "doc.html").replace("info", "doc.html");
            window.open(url);
        });
    })
</script>
<body>

</body>
</html>
